package d1130.r211.num16;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Tools {

    //平均分
    public  static  double getAvg(List<Student> studentList){
        double sum=0;
        for (Student student : studentList) {
            sum+=student.getScore();
        }

        return sum/studentList.size();
    }
    //不及格
    public static List<Student> getScore(List<Student> list) {
        List<Student> stus = new ArrayList<>();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            Student stu = (Student) it.next();
            if (stu.getScore() < 60) {
                stus.add( stu);

            }

        }
        return  stus;
    }





    //最大值
  /* public static List<Student>getMax(List<Student> studentList) {
       Iterator<Student> it = studentList.listIterator();
       Student stuMax = it.next();
       while (it.hasNext()) {
           Student stu = it.next();
           if (it.next().getScore() > stuMax.getScore()) {
               stuMax = stu;
           }
       }


       return studentList;
   }*/}
